package com.lc202407;

import java.util.TreeSet;

public class Solution16_11 {
    public int[] divingBoard1(int shorter, int longer, int k) {
        if (k == 0) {
            return new int[0];
        }
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i <= k; i++) {
            set.add(longer * i + (k - i) * shorter);
        }
        int[] arr = new int[set.size()];
        int i = 0;
        for (Integer num : set) {
            arr[i] = num;
            i++;
        }
        return arr;
    }

    public int[] divingBoard(int shorter, int longer, int k) {
        if (k == 0) {
            return new int[]{};
        }
        if (shorter == longer) {
            return new int[]{shorter * k};
        }
        int[] arr = new int[k + 1];
        for (int i = 0; i <= k; i++) {
            arr[i] = longer * i + (k - i) * shorter;
        }
        return arr;
    }
}
